#!/bin/bash
# Copyright (c) 2020 Presto Labs Pte. Ltd.
# Author: donggu
set -e

set +e
git diff origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH...HEAD --name-only --diff-filter=ACDMRT \
| rg -v "experimental" \
| rg "((WORKSPACE|BUILD|^external/apiset$))|((\.bzl|\.c|\.cc|\.cpp|\.h|\.hpp)$)"

status=$?
set -e

if [ $status -eq 0 ]
then
source ~/miniconda3/etc/profile.d/conda.sh
conda activate coin2_env
./build-bazel.sh
else
echo 'no WORKSPACE|BUILD|external/apiset|.bzl|.c|.cc|.cpp|.h|.hpp file changed.'
fi
